apiVersion: apps/v1
kind: Deployment
metadata:
  name: postgres-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      components: postgres
  template:
    metadata:
      labels:
        components: postgres
    spec:
      containers:
      - name: postgres
        image: postgres:16.0
        resources:
          limits:
            memory: "500Mi"
            cpu: "300m"
        volumeMounts:
          - name: postgres-data
            mountPath: /var/lib/postgresql/data
            subPath: postgres
        ports:
          - containerPort: 5432
        env:
          - name: POSTGRES_DB
            value: demo
          - name: POSTGRES_USER
            value: demo
          - name: POSTGRES_PASSWORD
            value: demo
      volumes:
        - name: postgres-data
          persistentVolumeClaim:
            claimName: postgres-pvc

